﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Media;

namespace TicTacToeX {
	public static class AssetsManager {		
		/// <summary>
		/// Use this method to load all the textures in game
		/// </summary>
		/// <param name="currentGame"></param>
		public static void Initialize(Game currentGame) {
			currentGame.Content.RootDirectory = "Content";

			Assets.SpriteBatch  = new SpriteBatch(currentGame.GraphicsDevice);
			Assets.Cursor       = currentGame.Content.Load<Texture2D>("texture-Cursor");
			Assets.Grid         = currentGame.Content.Load<Texture2D>("texture-Cell");
			Assets.PlayerOne    = currentGame.Content.Load<Texture2D>("texture-X");
			Assets.PlayerTwo    = currentGame.Content.Load<Texture2D>("texture-O");
			Assets.Font         = currentGame.Content.Load<SpriteFont>("font");
			Assets.BackgroungFX = currentGame.Content.Load<Song>("bgSound");

			Size.Grid      = new Vector2(Assets.Grid.Width,Assets.Grid.Height);
			Size.PlayerOne = new Vector2(Assets.PlayerOne.Width,Assets.PlayerOne.Height);
			Size.PlayerTwo = new Vector2(Assets.PlayerTwo.Width,Assets.PlayerTwo.Height);

			BackgroundSettingsFX();
		}

		private static void BackgroundSettingsFX() {
			MediaPlayer.Play(Assets.BackgroungFX);
			MediaPlayer.IsRepeating = true;
			IsMutedBackgroundFX(true);
		}

		private static void IsMutedBackgroundFX(bool muted) {
			MediaPlayer.IsMuted = muted;
		}
	}
}
